<?php
	class Mailer {
		public function send( $to, $subject, $message ) {
			#	[php.ini]
			#	sendmail_path = C:\_apm\sendmail\sendmail -t
			#
			#	[sendmail.ini]
			#	smtp_server=smtp.gmail.com
			#	smtp_port=587
			#	auth_username=naiyumie@gmail.com
			#	auth_password=ayaxyz1425
			#	force_sender=naiyumie@gmail.com

			# recipients
			# $to  = "naiyumie@naver.com" . ", " ; // 콤마인 것에 주의.
			# $to .= "naiyumie@gmail.com";

			# subject
			# $subject = "change_again";

			# message
			# $message = '
			#	<table border="1">
			#		<tr>
			#			<td>hello</td>
			#		</tr>
			#	</table>
			# ';
			 /*
			$to = $useremail;;
			$fname = "마스터";
			$mail_from=master@master.com;
			$subject = "[마스터] " . $saju_user . "님의 내용입니다..";
			$header ="Content-Type: text/html; charset=EUC-KR\r\n";

			//$header ="Content-Type: text/html; charset=EUC-KR\n";
			// $header .= "Return-Path: <$mail_from>\n";
			$header .= "From: $fname <$mail_from>\n";


			// $strContent=iconv("UTF-8","EUC-KR",$strContent);

			// $bodys= "$body\r\n\r\n";
			//$body .= chunk_split(base64_encode($body))."\r\n\r\n";
			$body .=iconv("UTF-8","EUC-KR",$body);


			mail($to, $subject, $body, $header, '-f'.$mail_from);
			*/


			$to = iconv("UTF-8","EUC-KR", $to);
			$subject = iconv("UTF-8","EUC-KR", $subject);
			$message = iconv("UTF-8","EUC-KR", $message);


			# HTML 메일을 보내려면, Content-type 헤더를 설정해야 합니다.
			$headers  = "MIME-Version: 1.0\r\n";
			$headers .= "Content-type: text/html; charset=EUC-KR\r\n";

			/* 추가 헤더 */
			//$headers .= "To: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n";
			//$headers .= "From: naiyumie <naiyumie@gmail.com>\r\n";
			//$headers .= "Cc: birthdayarchive@example.com\r\n";
			//$headers .= "Bcc: birthdaycheck@example.com\r\n";

			/* 그리고 메일을 보냅니다. */
			$sending = mail($to, $subject, $message, $headers);
			if($sending){
				return TRUE;
			} else {
				return FALSE;
			}
		}

		public function linux() {
			$fd = popen("/usr/sbin/sendmail -t","w") or die("Couldn't Open Sendmail");
			fputs($fd, "To: recipient@hisdomain.com \n");
			fputs($fd, "From: \"Your Name\" <youremail@yourdomain.com> \n");
			fputs($fd, "Subject: Test message from my web site \n");
			fputs($fd, "X-Mailer: PHP3 \n\n");
			fputs($fd, "Testing. \n");
			pclose($fd);
		}
	}

?>